<template>

    <div class="nav" :class="{ isTop: isTop }">
        <div home-container class="nav-box">
            <div class="flex">
                <img class="nav-logo" v-if="isTop" src="/images/home/img_logo_d_w.png" alt="">
                <img class="nav-logo" v-else src="/images/home/img_logo_d_w.png" alt="">
                <div class="nav-menus">
                    <div class="menus-item" @click="onClick(index)" v-for="(item, index) in menus" :key="index"
                        :class="{ 'menus-item-active': active == index }">
                        <a href="">{{ item }}</a>
                    </div>

                </div>
            </div>
            <div class="login-Registration">
                <span>注册</span>
                <span>登录</span>
            </div>
        </div>

    </div>
</template>

<script setup>
const { isTop } = defineProps(['isTop'])
const active = ref(0);
const menus = ref([
    '首页',
    '岗位',
    '资讯',
    '个人中心',
])


const onClick = (index) => {
    active.value = index;

}

</script>

<style scoped lang="scss">
.nav {
    height: 48px;
    width: 100%;
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;

    .nav-box {
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin: 0 auto;
    }

    .flex {
        align-items: center;
    }

    &-logo {
        width: 123px;
        height: 30px;
    }

    &-menus {
        align-items: center;
        height: 48px;
        display: flex;
        margin-left: 100px;

        .menus-item {
            position: relative;
            padding: 0 20px;
            text-align: center;
            cursor: pointer;

            a {
                color: #fff;
            }
        }

        .menus-item:hover::before,
        .menus-item-active::before {
            content: '';
            position: absolute;
            bottom: -4px;
            width: calc(100% - 40px);
            height: 2px;
            left: 20px;
            background: #fff;
        }
    }
}

.login-Registration {
    display: flex;
    height: 48px;
    align-items: center;

    span {
        display: inline-block;
        padding: 2px 10px;
        margin: 0 10px;
        cursor: pointer;
        font-size: 14px;
        border-radius: 4px;
        border: 1px solid #fff;
    }
}

.isTop {
    background: #fff;
    color: #000;
    z-index: 1999;

    .nav-menus {
        align-items: center;
        height: 48px;
        display: flex;
        margin-left: 100px;

        .menus-item {
            position: relative;
            padding: 0 20px;
            text-align: center;
            cursor: pointer;

            a {
                color: #000;
            }
        }

        .menus-item:hover::before,
        .menus-item-active::before {
            content: '';
            position: absolute;
            bottom: -4px;
            width: calc(100% - 40px);
            height: 2px;
            left: 20px;
            background: #4062FF;
        }
    }
}
</style>